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 11 pull requests #104418

Merged
merged 25 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fc380ec
Adjust `tcp_quickack` feature to allow other `os::linux::net` features.
jmillikin Sep 18, 2022
8f1e6eb
Move `unix_socket_abstract` feature API to `SocketAddrExt`.
jmillikin Sep 18, 2022
12c15a2
Split out from_u32_unchecked from const_char_convert
est31 Sep 29, 2022
176c44c
Stabilize const_char_convert
est31 Sep 29, 2022
f902b49
Don't print full paths in overlap errors
compiler-errors Nov 10, 2022
c2b906b
Recover from fn ptr tys with generic param list
fmease Nov 10, 2022
93921dd
Don't ICE with inline const errors during MIR build
compiler-errors Nov 11, 2022
d8c0fef
Fixed some `_i32` notation in `maybe_uninit`’s doc
Elarcis Nov 12, 2022
442f848
fix some typos in comments
cuishuang Nov 13, 2022
56dfb70
use `EXE_EXTENSION` while searching for python
SparkyPotato Nov 13, 2022
7982d6a
interpret: make check_mplace public
RalfJung Nov 13, 2022
8e81cc2
rustdoc: Resolve doc links in external traits having local impls
petrochenkov Nov 13, 2022
6de5f62
Bump chalk to v0.87
compiler-errors Nov 13, 2022
36a1068
Make rustc build with new chalk
compiler-errors Nov 13, 2022
9f3786b
Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=jos…
matthiaskrgr Nov 14, 2022
8c77da8
Rollup merge of #102470 - est31:stabilize_const_char_convert, r=josht…
matthiaskrgr Nov 14, 2022
a86bdb4
Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=este…
matthiaskrgr Nov 14, 2022
abda584
Rollup merge of #104229 - compiler-errors:overlap-full-path, r=davidtwco
matthiaskrgr Nov 14, 2022
f8e5b1c
Rollup merge of #104294 - compiler-errors:inline-ct-err-in-mir-build,…
matthiaskrgr Nov 14, 2022
43bb507
Rollup merge of #104332 - Elarcis:maybe_uninit_doc_fix, r=m-ou-se
matthiaskrgr Nov 14, 2022
5763fa7
Rollup merge of #104349 - rustaceanclub:master, r=oli-obk
matthiaskrgr Nov 14, 2022
aa29a8b
Rollup merge of #104350 - SparkyPotato:fix-x-wrapper, r=jyn514
matthiaskrgr Nov 14, 2022
050ece6
Rollup merge of #104356 - RalfJung:interpret-check-mplace, r=oli-obk
matthiaskrgr Nov 14, 2022
dc869fc
Rollup merge of #104364 - petrochenkov:docice2, r=GuillaumeGomez
matthiaskrgr Nov 14, 2022
c389097
Rollup merge of #104378 - compiler-errors:chalk-up, r=jackh726
matthiaskrgr Nov 14, 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
16 changes: 8 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ dependencies = [

[[package]]
name = "chalk-derive"
version = "0.80.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0001adf0cf12361e08b65e1898ea138f8f77d8f5177cbf29b6b3b3532252bd6"
checksum = "d552b2fa341f5fc35c6b917b1d289d3c3a34d0b74e579390ea6192d6152a8cdb"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -514,9 +514,9 @@ dependencies = [

[[package]]
name = "chalk-engine"
version = "0.80.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c44ee96f2d67cb5193d1503f185db1abad9933a1c6e6b4169c176f90baecd393"
checksum = "7e54ac43048cb31c470d7b3e3acd409090ef4a5abddfe02455187aebc3d6879f"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -527,9 +527,9 @@ dependencies = [

[[package]]
name = "chalk-ir"
version = "0.80.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d8a95548f23618fda86426e4304e563ec2bb7ba0216139f0748d63c107b5f1"
checksum = "43aa55deff4e7fbdb09fa014543372f2c95a06835ac487b9ce57b5099b950838"
dependencies = [
"bitflags",
"chalk-derive",
Expand All @@ -538,9 +538,9 @@ dependencies = [

[[package]]
name = "chalk-solve"
version = "0.80.0"
version = "0.87.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f37f492dacfafe2e21319b80827da2779932909bb392f0cc86b2bd5c07c1b4e1"
checksum = "61213deefc36ba265ad01c4d997e18bcddf7922862a4594a47ca4575afb3dab4"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

/// Read an immediate from a place, asserting that that is possible with the given layout.
///
/// If this suceeds, the `ImmTy` is never `Uninit`.
/// If this succeeds, the `ImmTy` is never `Uninit`.
#[inline(always)]
pub fn read_immediate(
&self,
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ where
Ok(MPlaceTy { mplace, layout, align })
}

/// Take an operand, representing a pointer, and dereference it to a place -- that
/// will always be a MemPlace. Lives in `place.rs` because it creates a place.
/// Take an operand, representing a pointer, and dereference it to a place.
#[instrument(skip(self), level = "debug")]
pub fn deref_operand(
&self,
Expand All @@ -331,7 +330,7 @@ where
}

let mplace = self.ref_to_mplace(&val)?;
self.check_mplace_access(mplace, CheckInAllocMsg::DerefTest)?;
self.check_mplace(mplace)?;
Ok(mplace)
}

Expand All @@ -358,17 +357,18 @@ where
}

/// Check if this mplace is dereferenceable and sufficiently aligned.
fn check_mplace_access(
&self,
mplace: MPlaceTy<'tcx, M::Provenance>,
msg: CheckInAllocMsg,
) -> InterpResult<'tcx> {
pub fn check_mplace(&self, mplace: MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx> {
let (size, align) = self
.size_and_align_of_mplace(&mplace)?
.unwrap_or((mplace.layout.size, mplace.layout.align.abi));
assert!(mplace.align <= align, "dynamic alignment less strict than static one?");
let align = M::enforce_alignment(self).then_some(align);
self.check_ptr_access_align(mplace.ptr, size, align.unwrap_or(Align::ONE), msg)?;
self.check_ptr_access_align(
mplace.ptr,
size,
align.unwrap_or(Align::ONE),
CheckInAllocMsg::DerefTest,
)?;
Ok(())
}

Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parser.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,12 @@ parser_async_move_order_incorrect = the order of `move` and `async` is incorrect

parser_double_colon_in_bound = expected `:` followed by trait or lifetime
.suggestion = use single colon

parser_fn_ptr_with_generics = function pointer types may not have generic parameters
.suggestion = consider moving the lifetime {$arity ->
[one] parameter
*[other] parameters
} to {$for_param_list_exists ->
[true] the
*[false] a
} `for` parameter list
4 changes: 4 additions & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,10 @@ impl HandlerInner {
}

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're Level::Allowed,
// but they still need to be constructed and stashed below,
// so they'll trigger the good-path bug check.
self.suppressed_expected_diag = true;
self.future_breakage_diagnostics.push(diagnostic.clone());
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ fn expand_macro<'cx>(
assert!(try_success_result.is_err(), "Macro matching returned a success on the second try");

if let Some(result) = tracker.result {
// An irrecoverable error occured and has been emitted.
// An irrecoverable error occurred and has been emitted.
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub enum AttributeDuplicates {
FutureWarnPreceding,
}

/// A conveniece macro to deal with `$($expr)?`.
/// A convenience macro to deal with `$($expr)?`.
macro_rules! or_default {
($default:expr,) => {
$default
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ClosureSignatures<'tcx> {
bound_sig: ty::PolyFnSig<'tcx>,
/// The signature within the function body.
/// This mostly differs in the sense that lifetimes are now early bound and any
/// opaque types from the signature expectation are overriden in case there are
/// opaque types from the signature expectation are overridden in case there are
/// explicit hidden types written by the user in the closure signature.
liberated_sig: ty::FnSig<'tcx>,
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ fn lint_int_literal<'tcx>(
}

if lint_overflowing_range_endpoint(cx, lit, v, max, e, t.name_str()) {
// The overflowing literal lint was emited by `lint_overflowing_range_endpoint`.
// The overflowing literal lint was emitted by `lint_overflowing_range_endpoint`.
return;
}

Expand Down Expand Up @@ -429,7 +429,7 @@ fn lint_uint_literal<'tcx>(
}
}
if lint_overflowing_range_endpoint(cx, lit, lit_val, max, e, t.name_str()) {
// The overflowing literal lint was emited by `lint_overflowing_range_endpoint`.
// The overflowing literal lint was emitted by `lint_overflowing_range_endpoint`.
return;
}
if let Some(repr_str) = get_bin_hex_repr(cx, lit) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ doctest = false

[dependencies]
bitflags = "1.2.1"
chalk-ir = "0.80.0"
chalk-ir = "0.87.0"
either = "1.5.0"
gsgdt = "0.1.2"
polonius-engine = "0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ impl<'tcx> Place<'tcx> {
/// If MirPhase >= Derefered and if projection contains Deref,
/// It's guaranteed to be in the first place
pub fn has_deref(&self) -> bool {
// To make sure this is not accidently used in wrong mir phase
// To make sure this is not accidentally used in wrong mir phase
debug_assert!(
self.projection.is_empty() || !self.projection[1..].contains(&PlaceElem::Deref)
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub enum MirPhase {
///
/// Also note that the lint pass which reports eg `200_u8 + 200_u8` as an error is run as a part
/// of analysis to runtime MIR lowering. To ensure lints are reported reliably, this means that
/// transformations which may supress such errors should not run on analysis MIR.
/// transformations which may suppress such errors should not run on analysis MIR.
Runtime(RuntimePhase),
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
else_block: Some(else_block),
} => {
// When lowering the statement `let <pat> = <expr> else { <else> };`,
// the `<else>` block is nested in the parent scope enclosing this statment.
// the `<else>` block is nested in the parent scope enclosing this statement.
// That scope is usually either the enclosing block scope,
// or the remainder scope of the last statement.
// This is to make sure that temporaries instantiated in `<expr>` are dropped
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
self.errors.push(PatternError::ConstParamInPattern(span));
return PatKind::Wild;
}
ConstKind::Error(_) => {
return PatKind::Wild;
}
_ => bug!("Expected ConstKind::Param"),
},
mir::ConstantKind::Val(_, _) => self.const_to_pat(value, id, span, false).kind,
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,3 +1280,24 @@ pub(crate) struct DoubleColonInBound {
#[suggestion(code = ": ", applicability = "machine-applicable")]
pub between: Span,
}

#[derive(Diagnostic)]
#[diag(parser_fn_ptr_with_generics)]
pub(crate) struct FnPtrWithGenerics {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub sugg: Option<FnPtrWithGenericsSugg>,
}

#[derive(Subdiagnostic)]
#[multipart_suggestion(suggestion, applicability = "maybe-incorrect")]
pub(crate) struct FnPtrWithGenericsSugg {
#[suggestion_part(code = "{snippet}")]
pub left: Span,
pub snippet: String,
#[suggestion_part(code = "")]
pub right: Span,
pub arity: usize,
pub for_param_list_exists: bool,
}
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![feature(array_windows)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(never_type)]
#![feature(rustc_attrs)]
Expand Down
58 changes: 55 additions & 3 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{Parser, PathStyle, TokenType};

use crate::errors::{FnPtrWithGenerics, FnPtrWithGenericsSugg};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};

use rustc_ast::ptr::P;
Expand Down Expand Up @@ -270,14 +271,19 @@ impl<'a> Parser<'a> {
TyKind::Infer
} else if self.check_fn_front_matter(false, Case::Sensitive) {
// Function pointer type
self.parse_ty_bare_fn(lo, Vec::new(), recover_return_sign)?
self.parse_ty_bare_fn(lo, Vec::new(), None, recover_return_sign)?
} else if self.check_keyword(kw::For) {
// Function pointer type or bound list (trait object type) starting with a poly-trait.
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
let lifetime_defs = self.parse_late_bound_lifetime_defs()?;
if self.check_fn_front_matter(false, Case::Sensitive) {
self.parse_ty_bare_fn(lo, lifetime_defs, recover_return_sign)?
self.parse_ty_bare_fn(
lo,
lifetime_defs,
Some(self.prev_token.span.shrink_to_lo()),
recover_return_sign,
)?
} else {
let path = self.parse_path(PathStyle::Type)?;
let parse_plus = allow_plus == AllowPlus::Yes && self.check_plus();
Expand Down Expand Up @@ -519,7 +525,8 @@ impl<'a> Parser<'a> {
fn parse_ty_bare_fn(
&mut self,
lo: Span,
params: Vec<GenericParam>,
mut params: Vec<GenericParam>,
param_insertion_point: Option<Span>,
recover_return_sign: RecoverReturnSign,
) -> PResult<'a, TyKind> {
let inherited_vis = rustc_ast::Visibility {
Expand All @@ -530,6 +537,9 @@ impl<'a> Parser<'a> {
let span_start = self.token.span;
let ast::FnHeader { ext, unsafety, constness, asyncness } =
self.parse_fn_front_matter(&inherited_vis)?;
if self.may_recover() && self.token.kind == TokenKind::Lt {
self.recover_fn_ptr_with_generics(lo, &mut params, param_insertion_point)?;
}
let decl = self.parse_fn_decl(|_| false, AllowPlus::No, recover_return_sign)?;
let whole_span = lo.to(self.prev_token.span);
if let ast::Const::Yes(span) = constness {
Expand All @@ -545,6 +555,48 @@ impl<'a> Parser<'a> {
Ok(TyKind::BareFn(P(BareFnTy { ext, unsafety, generic_params: params, decl, decl_span })))
}

/// Recover from function pointer types with a generic parameter list (e.g. `fn<'a>(&'a str)`).
fn recover_fn_ptr_with_generics(
&mut self,
lo: Span,
params: &mut Vec<GenericParam>,
param_insertion_point: Option<Span>,
) -> PResult<'a, ()> {
let generics = self.parse_generics()?;
let arity = generics.params.len();

let mut lifetimes: Vec<_> = generics
.params
.into_iter()
.filter(|param| matches!(param.kind, ast::GenericParamKind::Lifetime))
.collect();

let sugg = if !lifetimes.is_empty() {
let snippet =
lifetimes.iter().map(|param| param.ident.as_str()).intersperse(", ").collect();

let (left, snippet) = if let Some(span) = param_insertion_point {
(span, if params.is_empty() { snippet } else { format!(", {snippet}") })
} else {
(lo.shrink_to_lo(), format!("for<{snippet}> "))
};

Some(FnPtrWithGenericsSugg {
left,
snippet,
right: generics.span,
arity,
for_param_list_exists: param_insertion_point.is_some(),
})
} else {
None
};

self.sess.emit_err(FnPtrWithGenerics { span: generics.span, sugg });
params.append(&mut lifetimes);
Ok(())
}

/// Emit an error for the given bad function pointer qualifier.
fn error_fn_ptr_bad_qualifier(&self, span: Span, qual_span: Span, qual: &str) {
self.struct_span_err(span, &format!("an `fn` pointer type cannot be `{}`", qual))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/effective_visibilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'r, 'a> EffectiveVisibilitiesVisitor<'r, 'a> {
update(node_id);
if let ImportKind::Single { additional_ids: (id1, id2), .. } = import.kind {
// In theory all the single import IDs have individual visibilities and
// effective visibilities, but in practice these IDs go straigth to HIR
// effective visibilities, but in practice these IDs go straight to HIR
// where all their few uses assume that their (effective) visibility
// applies to the whole syntactic `use` item. So they all get the same
// value which is the maximum of all bindings. Maybe HIR for imports
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,11 @@ impl<'a> Resolver<'a> {
}
}

/// For rustdoc.
pub fn get_partial_res(&self, node_id: NodeId) -> Option<PartialRes> {
self.partial_res_map.get(&node_id).copied()
}

/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.
#[inline]
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub enum Lld {
/// relevant now.
///
/// The second goal is to keep the number of flavors to the minimum if possible.
/// LLD somewhat forces our hand here because that linker is self-sufficent only if its executable
/// LLD somewhat forces our hand here because that linker is self-sufficient only if its executable
/// (`argv[0]`) is named in specific way, otherwise it doesn't work and requires a
/// `-flavor LLD_FLAVOR` argument to choose which logic to use. Our shipped `rust-lld` in
/// particular is not named in such specific way, so it needs the flavor option, so we make our
Expand Down
Loading