Skip to content
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

Rollup of 13 pull requests #104167

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6d45529
Fix #103451, find_width_of_character_at_span return width with 1 when…
chenyukang Oct 25, 2022
a2f3649
Add support for custom MIR parsing
JakobDegen Aug 3, 2022
a2037e3
Check for substs compatibility for RPITITs
compiler-errors Nov 1, 2022
32dae91
Remap RPITIT substs properly
compiler-errors Nov 1, 2022
0f632c8
Fix ICE in default impl error reporting
compiler-errors Nov 1, 2022
cf6efe8
Add test case
wesleywiser Oct 25, 2022
296489c
Fix Access Violation when using lld & ThinLTO on windows-msvc
wesleywiser Oct 20, 2022
f8e2cef
Move intra-doc link checks to a separate function.
ehuss Nov 4, 2022
57b2290
Remove reference from the intra-doc link checker.
ehuss Nov 4, 2022
e49d10d
first move on a nested span_label
AndyJado Oct 26, 2022
13d4c61
Place config.toml in current working directory if config not found
ted-tanner Nov 5, 2022
17044c1
disable btree size tests on Miri
RalfJung Nov 7, 2022
780952f
run alloc benchmarks in Miri and fix UB
RalfJung Nov 7, 2022
29d451c
fmt
RalfJung Nov 7, 2022
4c3cad0
Add --print=split-debuginfo
kamirr Nov 7, 2022
66e8a29
Only set config.config to None when using default path
ted-tanner Nov 7, 2022
1f21b96
add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'
chenyukang Nov 3, 2022
465ac26
deprecate unchecked_claim_error_was_emitted in error_reported
chenyukang Nov 4, 2022
3320879
code cleanup with err.emit_unless
chenyukang Nov 4, 2022
667b15b
fix #103587, Recover from common if let syntax mistakes/typos
chenyukang Oct 27, 2022
9e7d228
use subdiagnostic for sugesting add let
chenyukang Nov 8, 2022
9eb977b
Add llvm-main to triagebot.toml
Manishearth Nov 8, 2022
b760d04
Rollup merge of #103353 - wesleywiser:fix_lld_thinlto_msvc, r=michael…
Manishearth Nov 8, 2022
eac2f83
Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obk
Manishearth Nov 8, 2022
71b8f42
Rollup merge of #103521 - chenyukang:yukang/fix-103451-avoid-hang, r=…
Manishearth Nov 8, 2022
80ef19c
Rollup merge of #103559 - AndyJado:var_span_label, r=davidtwco
Manishearth Nov 8, 2022
0dfd52b
Rollup merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, r…
Manishearth Nov 8, 2022
04defb6
Rollup merge of #103827 - compiler-errors:rpitit-substs-compat, r=wes…
Manishearth Nov 8, 2022
45cd0c6
Rollup merge of #103928 - chenyukang:yukang/fix-103874-add-ty_error_w…
Manishearth Nov 8, 2022
f2a7d56
Rollup merge of #103952 - ehuss:dont-intra-linkcheck-reference, r=Mar…
Manishearth Nov 8, 2022
2b70c6a
Rollup merge of #104027 - ted-tanner:issue-103697-fix, r=jyn514
Manishearth Nov 8, 2022
7871ede
Rollup merge of #104093 - RalfJung:test-sizes, r=thomcc
Manishearth Nov 8, 2022
62dd898
Rollup merge of #104097 - RalfJung:miri-alloc-benches, r=thomcc
Manishearth Nov 8, 2022
925045b
Rollup merge of #104104 - kamirr:master, r=lcnr
Manishearth Nov 8, 2022
4468412
Rollup merge of #104165 - Manishearth:triagebot-llvm, r=Mark-Simulacrum
Manishearth Nov 8, 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
14 changes: 10 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,13 +724,19 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
borrow_span,
&self.describe_any_place(borrow.borrowed_place.as_ref()),
);

borrow_spans.var_span_label(
borrow_spans.var_subdiag(
&mut err,
{
|var_span| {
use crate::session_diagnostics::CaptureVarCause::*;
let place = &borrow.borrowed_place;
let desc_place = self.describe_any_place(place.as_ref());
format!("borrow occurs due to use of {}{}", desc_place, borrow_spans.describe())
match borrow_spans {
UseSpans::ClosureUse { generator_kind, .. } => match generator_kind {
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
None => BorrowUsePlaceClosure { place: desc_place, var_span },
},
_ => BorrowUsePlace { place: desc_place, var_span },
}
},
"mutable",
);
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,26 @@ impl UseSpans<'_> {
}
}

/// Add a subdiagnostic to the use of the captured variable, if it exists.
pub(super) fn var_subdiag(
self,
err: &mut Diagnostic,
f: impl Fn(Span) -> crate::session_diagnostics::CaptureVarCause,
kind_desc: impl Into<String>,
) {
if let UseSpans::ClosureUse { capture_kind_span, path_span, .. } = self {
if capture_kind_span == path_span {
err.subdiagnostic(f(capture_kind_span));
} else {
err.subdiagnostic(crate::session_diagnostics::CaptureVarKind {
kind_desc: kind_desc.into(),
kind_span: capture_kind_span,
});
err.subdiagnostic(f(path_span));
}
}
}

/// Returns `false` if this place is not used in a closure.
pub(super) fn for_closure(&self) -> bool {
match *self {
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern crate tracing;

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
Expand Down Expand Up @@ -129,6 +130,19 @@ fn mir_borrowck<'tcx>(
) -> &'tcx BorrowCheckResult<'tcx> {
let (input_body, promoted) = tcx.mir_promoted(def);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def.did.to_def_id()));

if input_body.borrow().should_skip() {
debug!("Skipping borrowck because of injected body");
// Let's make up a borrowck result! Fun times!
let result = BorrowCheckResult {
concrete_opaque_types: VecMap::new(),
closure_requirements: None,
used_mut_upvars: SmallVec::new(),
tainted_by_errors: None,
};
return tcx.arena.alloc(result);
}

let hir_owner = tcx.hir().local_def_id_to_hir_id(def.did).owner;

let infcx =
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
if errors.is_empty() {
definition_ty
} else {
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
self.tcx.ty_error()
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
self.tcx.ty_error_with_guaranteed(reported)
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions compiler/rustc_borrowck/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,33 @@ pub(crate) enum RequireStaticErr {
multi_span: MultiSpan,
},
}

#[derive(Subdiagnostic)]
#[label(borrowck_capture_kind_label)]
pub(crate) struct CaptureVarKind {
pub kind_desc: String,
#[primary_span]
pub kind_span: Span,
}

#[derive(Subdiagnostic)]
pub(crate) enum CaptureVarCause {
#[label(borrowck_var_borrow_by_use_place)]
BorrowUsePlace {
place: String,
#[primary_span]
var_span: Span,
},
#[label(borrowck_var_borrow_by_use_place_in_generator)]
BorrowUsePlaceGenerator {
place: String,
#[primary_span]
var_span: Span,
},
#[label(borrowck_var_borrow_by_use_place_in_closure)]
BorrowUsePlaceClosure {
place: String,
#[primary_span]
var_span: Span,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
.and(type_op::normalize::Normalize::new(ty))
.fully_perform(self.infcx)
.unwrap_or_else(|_| {
self.infcx
let reported = self
.infcx
.tcx
.sess
.delay_span_bug(span, &format!("failed to normalize {:?}", ty));
TypeOpOutput {
output: self.infcx.tcx.ty_error(),
output: self.infcx.tcx.ty_error_with_guaranteed(reported),
constraints: None,
error_info: None,
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ pub(crate) fn type_check<'mir, 'tcx>(
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
if hidden_type.has_non_region_infer() {
infcx.tcx.sess.delay_span_bug(
let reported = infcx.tcx.sess.delay_span_bug(
decl.hidden_type.span,
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
);
hidden_type.ty = infcx.tcx.ty_error();
hidden_type.ty = infcx.tcx.ty_error_with_guaranteed(reported);
}

(opaque_type_key, (hidden_type, decl.origin))
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use rustc_middle::mir::mono::MonoItem;
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_middle::{bug, span_bug};
use rustc_session::config::Lto;
use rustc_target::abi::{
AddressSpace, Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange,
};
Expand Down Expand Up @@ -303,7 +304,8 @@ impl<'ll> CodegenCx<'ll, '_> {
// ThinLTO can't handle this workaround in all cases, so we don't
// emit the attrs. Instead we make them unnecessary by disallowing
// dynamic linking when linker plugin based LTO is enabled.
!self.tcx.sess.opts.cg.linker_plugin_lto.enabled();
!self.tcx.sess.opts.cg.linker_plugin_lto.enabled() &&
self.tcx.sess.lto() != Lto::Thin;

// If this assertion triggers, there's something wrong with commandline
// argument validation.
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,17 @@ fn print_crate_info(
// Any output here interferes with Cargo's parsing of other printed output
NativeStaticLibs => {}
LinkArgs => {}
SplitDebuginfo => {
use rustc_target::spec::SplitDebuginfo::{Off, Packed, Unpacked};

for split in &[Off, Packed, Unpacked] {
let stable = sess.target.options.supported_split_debuginfo.contains(split);
let unstable_ok = sess.unstable_options();
if stable || unstable_ok {
println!("{}", split);
}
}
}
}
}
Compilation::Stop
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/borrowck.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ borrowck_returned_lifetime_short =

borrowck_used_impl_require_static =
the used `impl` has a `'static` requirement

borrowck_capture_kind_label =
capture is {$kind_desc} because of use here

borrowck_var_borrow_by_use_place_in_generator =
borrow occurs due to use of {$place} in closure in generator

borrowck_var_borrow_by_use_place_in_closure =
borrow occurs due to use of {$place} in closure

borrowck_var_borrow_by_use_place =
borrow occurs due to use of {$place}
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/locales/en-US/infer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,4 @@ infer_msl_introduces_static = introduces a `'static` lifetime requirement
infer_msl_unmet_req = because this has an unmet lifetime requirement
infer_msl_trait_note = this has an implicit `'static` lifetime requirement
infer_msl_trait_sugg = consider relaxing the implicit `'static` requirement
infer_suggest_add_let_for_letchains = consider adding `let`
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parser.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ parser_if_expression_missing_condition = missing condition for `if` expression

parser_expected_expression_found_let = expected expression, found `let` statement

parser_expect_eq_instead_of_eqeq = expected `=`, found `==`
.suggestion = consider using `=` here

parser_expected_else_block = expected `{"{"}`, found {$first_tok}
.label = expected an `if` or a block after this `else`
.suggestion = add an `if` if this is the condition of a chained `else if` statement
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
/// In the meantime, though, callsites are required to deal with the "bug"
/// locally in whichever way makes the most sense.
#[track_caller]
pub fn delay_as_bug(&mut self) {
pub fn delay_as_bug(&mut self) -> G {
self.downgrade_to_delayed_bug();
self.emit();
self.emit()
}

forward!(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ declare_features! (
(active, anonymous_lifetime_in_impl_trait, "1.63.0", None, None),
/// Allows identifying the `compiler_builtins` crate.
(active, compiler_builtins, "1.13.0", None, None),
/// Allows writing custom MIR
(active, custom_mir, "1.65.0", None, None),
/// Outputs useful `assert!` messages
(active, generic_assert, "1.63.0", None, None),
/// Allows using the `rust-intrinsic`'s "ABI".
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_attr!(TEST, rustc_polymorphize_error, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_def_path, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ..."), DuplicatesOk),
gated!(
custom_mir, Normal, template!(List: r#"dialect = "...", phase = "...""#),
ErrorFollowing, "the `#[custom_mir]` attribute is just used for the Rust test suite",
),
rustc_attr!(TEST, rustc_dump_program_clauses, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_dump_env_program_clauses, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_object_lifetime_default, Normal, template!(Word), WarnFollowing),
Expand Down
26 changes: 15 additions & 11 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
(_, _) => {
let got = if let Some(_) = term.ty() { "type" } else { "constant" };
let expected = def_kind.descr(assoc_item_def_id);
tcx.sess
let reported = tcx
.sess
.struct_span_err(
binding.span,
&format!("expected {expected} bound, found {got}"),
Expand All @@ -1212,11 +1213,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
)
.emit();
term = match def_kind {
hir::def::DefKind::AssocTy => tcx.ty_error().into(),
hir::def::DefKind::AssocTy => {
tcx.ty_error_with_guaranteed(reported).into()
}
hir::def::DefKind::AssocConst => tcx
.const_error(
.const_error_with_guaranteed(
tcx.bound_type_of(assoc_item_def_id)
.subst(tcx, projection_ty.skip_binder().substs),
reported,
)
.into(),
_ => unreachable!(),
Expand Down Expand Up @@ -1334,8 +1338,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map(|&(trait_ref, _, _)| trait_ref.def_id())
.find(|&trait_ref| tcx.is_trait_alias(trait_ref))
.map(|trait_ref| tcx.def_span(trait_ref));
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
return tcx.ty_error();
let reported =
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
return tcx.ty_error_with_guaranteed(reported);
}

// Check that there are no gross object safety violations;
Expand All @@ -1345,14 +1350,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let object_safety_violations =
astconv_object_safety_violations(tcx, item.trait_ref().def_id());
if !object_safety_violations.is_empty() {
report_object_safety_error(
let reported = report_object_safety_error(
tcx,
span,
item.trait_ref().def_id(),
&object_safety_violations,
)
.emit();
return tcx.ty_error();
return tcx.ty_error_with_guaranteed(reported);
}
}

Expand Down Expand Up @@ -2112,13 +2117,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
"Type"
};

self.report_ambiguous_associated_type(
let reported = self.report_ambiguous_associated_type(
span,
type_name,
&path_str,
item_segment.ident.name,
);
return tcx.ty_error();
return tcx.ty_error_with_guaranteed(reported)
};

debug!("qpath_to_ty: self_type={:?}", self_ty);
Expand Down Expand Up @@ -2560,8 +2565,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
{
err.span_note(impl_.self_ty.span, "not a concrete type");
}
err.emit();
tcx.ty_error()
tcx.ty_error_with_guaranteed(err.emit())
} else {
self.normalize_ty(span, ty)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,11 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
collected_tys.insert(def_id, ty);
}
Err(err) => {
tcx.sess.delay_span_bug(
let reported = tcx.sess.delay_span_bug(
return_span,
format!("could not fully resolve: {ty} => {err:?}"),
);
collected_tys.insert(def_id, tcx.ty_error());
collected_tys.insert(def_id, tcx.ty_error_with_guaranteed(reported));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
}
_ => {}
}
err.emit();
self.tcx().ty_error()
self.tcx().ty_error_with_guaranteed(err.emit())
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
}

let Some(hidden) = locator.found else {
tcx.sess.emit_err(UnconstrainedOpaqueType {
let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
span: tcx.def_span(def_id),
name: tcx.item_name(tcx.local_parent(def_id).to_def_id()),
what: match tcx.hir().get(scope) {
Expand All @@ -708,7 +708,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
_ => "item",
},
});
return tcx.ty_error();
return tcx.ty_error_with_guaranteed(reported);
};

// Only check against typeck if we didn't already error
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,9 +1639,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
if visitor.ret_exprs.len() > 0 && let Some(expr) = expression {
self.note_unreachable_loop_return(&mut err, &expr, &visitor.ret_exprs);
}
err.emit_unless(unsized_return);
let reported = err.emit_unless(unsized_return);

self.final_ty = Some(fcx.tcx.ty_error());
self.final_ty = Some(fcx.tcx.ty_error_with_guaranteed(reported));
}
}
}
Expand Down
Loading