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 9 pull requests #105444

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7674ede
Detect long types in E0308 and write them to disk
estebank Nov 26, 2022
360c0a7
Tweak shortening logic to be less trigger happy
estebank Nov 26, 2022
73b371a
Further tweak the type shortening logic
estebank Nov 26, 2022
be02bd9
Remove unneeded test change
estebank Nov 26, 2022
360bcb6
fix test
estebank Nov 26, 2022
34b3c49
fix rebase
estebank Nov 28, 2022
427a079
kmc-solid: Use `expose_addr` and `from_exposed_addr` for pointer-inte…
kawadakk Dec 1, 2022
47f2f6d
kmc-solid: Add a stub implementation of `is_terminal`
kawadakk Dec 1, 2022
f482e55
kmc-solid: Address compiler warnings
kawadakk Dec 1, 2022
ae7633f
kmc-solid: Don't do `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
kawadakk Dec 1, 2022
e2d41f4
Make nested RPITIT inherit the parent opaque's generics.
cjgillot Dec 4, 2022
9397ea1
make retagging work even with 'unstable' places
RalfJung Dec 5, 2022
34c58e8
Stacked Borrows: factor the logic determining the new permissions on …
RalfJung Dec 5, 2022
e9dd591
Add help for `#![feature(impl_trait_in_fn_trait_return)]`
cuviper Dec 7, 2022
0669379
Don't silently ignore errors that happen during rendering
GuillaumeGomez Dec 7, 2022
eef61b4
Update rustdoc test to check its error output
GuillaumeGomez Dec 7, 2022
6ccd14a
Improve several aspects of the Rustdoc scrape-examples UI.
willcrichton Nov 27, 2022
acd70e6
Add explanations to scrape-examples integration test
willcrichton Dec 6, 2022
4574217
Only put title over example on large screens
willcrichton Dec 6, 2022
679d7ea
Include additional documentation for scrape-examples changes
willcrichton Dec 6, 2022
212d03d
Factor scrape-examples toggle test into a new file
willcrichton Dec 6, 2022
ae270f1
Update scrape-examples help, fix documentation typos
willcrichton Dec 6, 2022
bcdab87
Fix es-check
willcrichton Dec 6, 2022
0709e53
Fix rustdoc error with no providec crate-type, fix scrape examples bu…
willcrichton Dec 6, 2022
8a45938
Revert crate_types change, add new bin_crate field
willcrichton Dec 6, 2022
9499d2c
Improve calculation of scraped example minimized height
willcrichton Dec 7, 2022
8bc30cb
CI: add missing line continuation marker
ComputerDruid Dec 7, 2022
a3c4c2e
Fix warning when libcore is compiled with no_fp_fmt_parse
nbdd0121 Dec 8, 2022
27c0dd6
Rollup merge of #104922 - estebank:fur-elize, r=oli-obk
matthiaskrgr Dec 8, 2022
ee74286
Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=th…
matthiaskrgr Dec 8, 2022
b47fc78
Rollup merge of #105255 - cjgillot:issue-105197, r=compiler-errors
matthiaskrgr Dec 8, 2022
55e07fd
Rollup merge of #105317 - RalfJung:retag-rework, r=oli-obk
matthiaskrgr Dec 8, 2022
23ea785
Rollup merge of #105387 - willcrichton:scrape-examples-ui-improvement…
matthiaskrgr Dec 8, 2022
616a11a
Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errors
matthiaskrgr Dec 8, 2022
b475163
Rollup merge of #105427 - GuillaumeGomez:dont-silently-ignore-rustdoc…
matthiaskrgr Dec 8, 2022
9289c92
Rollup merge of #105433 - ComputerDruid:docker_continuation_fix, r=jy…
matthiaskrgr Dec 8, 2022
a147868
Rollup merge of #105434 - nbdd0121:lib, r=thomcc
matthiaskrgr Dec 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4348,6 +4348,7 @@ dependencies = [
"rustc_span",
"rustc_target",
"smallvec",
"termize",
"tracing",
"winapi",
]
Expand Down
32 changes: 21 additions & 11 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ enum ImplTraitContext {
},
/// Impl trait in type aliases.
TypeAliasesOpaqueTy,
/// `impl Trait` is unstably accepted in this position.
FeatureGated(ImplTraitPosition, Symbol),
/// `impl Trait` is not accepted in this position.
Disallowed(ImplTraitPosition),
}
Expand Down Expand Up @@ -1372,25 +1374,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
path
}
ImplTraitContext::Disallowed(
position @ (ImplTraitPosition::TraitReturn | ImplTraitPosition::ImplReturn),
) => {
ImplTraitContext::FeatureGated(position, feature) => {
self.tcx
.sess
.create_feature_err(
MisplacedImplTrait {
span: t.span,
position: DiagnosticArgFromDisplay(&position),
position: DiagnosticArgFromDisplay(position),
},
sym::return_position_impl_trait_in_trait,
*feature,
)
.emit();
hir::TyKind::Err
}
ImplTraitContext::Disallowed(position) => {
self.tcx.sess.emit_err(MisplacedImplTrait {
span: t.span,
position: DiagnosticArgFromDisplay(&position),
position: DiagnosticArgFromDisplay(position),
});
hir::TyKind::Err
}
Expand Down Expand Up @@ -1739,14 +1739,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} else {
match &decl.output {
FnRetTy::Ty(ty) => {
let mut context = if kind.return_impl_trait_allowed(self.tcx) {
let context = if kind.return_impl_trait_allowed(self.tcx) {
let fn_def_id = self.local_def_id(fn_node_id);
ImplTraitContext::ReturnPositionOpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
in_trait: matches!(kind, FnDeclKind::Trait),
}
} else {
ImplTraitContext::Disallowed(match kind {
let position = match kind {
FnDeclKind::Fn | FnDeclKind::Inherent => {
unreachable!("fn should allow in-band lifetimes")
}
Expand All @@ -1755,9 +1755,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
FnDeclKind::Pointer => ImplTraitPosition::PointerReturn,
FnDeclKind::Trait => ImplTraitPosition::TraitReturn,
FnDeclKind::Impl => ImplTraitPosition::ImplReturn,
})
};
match kind {
FnDeclKind::Trait | FnDeclKind::Impl => ImplTraitContext::FeatureGated(
position,
sym::return_position_impl_trait_in_trait,
),
_ => ImplTraitContext::Disallowed(position),
}
};
hir::FnRetTy::Return(self.lower_ty(ty, &mut context))
hir::FnRetTy::Return(self.lower_ty(ty, &context))
}
FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
}
Expand Down Expand Up @@ -1938,7 +1945,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
output,
span,
if in_trait && !this.tcx.features().return_position_impl_trait_in_trait {
ImplTraitContext::Disallowed(ImplTraitPosition::TraitReturn)
ImplTraitContext::FeatureGated(
ImplTraitPosition::TraitReturn,
sym::return_position_impl_trait_in_trait,
)
} else {
ImplTraitContext::ReturnPositionOpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
Expand Down
19 changes: 13 additions & 6 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_ast::{self as ast, *};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::GenericArg;
use rustc_span::symbol::{kw, Ident};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{BytePos, Span, DUMMY_SP};

use smallvec::{smallvec, SmallVec};
Expand Down Expand Up @@ -352,11 +352,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// fn f(_: impl Fn() -> impl Debug) -> impl Fn() -> impl Debug
// // disallowed --^^^^^^^^^^ allowed --^^^^^^^^^^
// ```
FnRetTy::Ty(ty)
if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. })
&& self.tcx.features().impl_trait_in_fn_trait_return =>
{
self.lower_ty(&ty, itctx)
FnRetTy::Ty(ty) if matches!(itctx, ImplTraitContext::ReturnPositionOpaqueTy { .. }) => {
if self.tcx.features().impl_trait_in_fn_trait_return {
self.lower_ty(&ty, itctx)
} else {
self.lower_ty(
&ty,
&ImplTraitContext::FeatureGated(
ImplTraitPosition::FnTraitReturn,
sym::impl_trait_in_fn_trait_return,
),
)
}
}
FnRetTy::Ty(ty) => {
self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::FnTraitReturn))
Expand Down
16 changes: 14 additions & 2 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,21 @@ pub trait Machine<'mir, 'tcx>: Sized {
Ok(())
}

/// Executes a retagging operation.
/// Executes a retagging operation for a single pointer.
/// Returns the possibly adjusted pointer.
#[inline]
fn retag(
fn retag_ptr_value(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_kind: mir::RetagKind,
val: &ImmTy<'tcx, Self::Provenance>,
) -> InterpResult<'tcx, ImmTy<'tcx, Self::Provenance>> {
Ok(val.clone())
}

/// Executes a retagging operation on a compound value.
/// Replaces all pointers stored in the given place.
#[inline]
fn retag_place_contents(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_kind: mir::RetagKind,
_place: &PlaceTy<'tcx, Self::Provenance>,
Expand Down
39 changes: 35 additions & 4 deletions compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_middle::mir;
use rustc_middle::mir::interpret::{InterpResult, Scalar};
use rustc_middle::ty::layout::LayoutOf;

use super::{InterpCx, Machine};
use super::{ImmTy, InterpCx, Machine};

/// Classify whether an operator is "left-homogeneous", i.e., the LHS has the
/// same type as the result.
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// Stacked Borrows.
Retag(kind, place) => {
let dest = self.eval_place(**place)?;
M::retag(self, *kind, &dest)?;
M::retag_place_contents(self, *kind, &dest)?;
}

Intrinsic(box ref intrinsic) => self.emulate_nondiverging_intrinsic(intrinsic)?,
Expand Down Expand Up @@ -247,10 +247,41 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.write_scalar(Scalar::from_machine_usize(len, self), &dest)?;
}

AddressOf(_, place) | Ref(_, _, place) => {
Ref(_, borrow_kind, place) => {
let src = self.eval_place(place)?;
let place = self.force_allocation(&src)?;
self.write_immediate(place.to_ref(self), &dest)?;
let val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
// A fresh reference was created, make sure it gets retagged.
let val = M::retag_ptr_value(
self,
if borrow_kind.allows_two_phase_borrow() {
mir::RetagKind::TwoPhase
} else {
mir::RetagKind::Default
},
&val,
)?;
self.write_immediate(*val, &dest)?;
}

AddressOf(_, place) => {
// Figure out whether this is an addr_of of an already raw place.
let place_base_raw = if place.has_deref() {
let ty = self.frame().body.local_decls[place.local].ty;
ty.is_unsafe_ptr()
} else {
// Not a deref, and thus not raw.
false
};

let src = self.eval_place(place)?;
let place = self.force_allocation(&src)?;
let mut val = ImmTy::from_immediate(place.to_ref(self), dest.layout);
if !place_base_raw {
// If this was not already raw, it needs retagging.
val = M::retag_ptr_value(self, mir::RetagKind::Raw, &val)?;
}
self.write_immediate(*val, &dest)?;
}

NullaryOp(null_op, ty) => {
Expand Down
16 changes: 1 addition & 15 deletions compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use hir::{
GenericParamKind, HirId, Node,
};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::lint;
Expand Down Expand Up @@ -143,20 +142,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
Some(tcx.typeck_root_def_id(def_id))
}
Node::Item(item) => match item.kind {
ItemKind::OpaqueTy(hir::OpaqueTy {
origin:
hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id),
in_trait,
..
}) => {
if in_trait {
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn))
} else {
assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn))
}
Some(fn_def_id.to_def_id())
}
ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias, .. }) => {
ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => {
let parent_id = tcx.hir().get_parent_item(hir_id);
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);
Expand Down
Loading