mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Update to Rust 1.78 (#32217)
* Update to rust 1.78 * Update crown for rust 1.78 * rust 1.78 is now stable * Update for nix * Update comment Co-authored-by: Martin Robinson <mrobinson@igalia.com> * Update support/crown/src/common.rs * Update support/crown/Cargo.toml * Update support/crown/src/common.rs * Fix ipc problem * Update ipc-channel to 0.18.1 * fixed fixme --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
1f4341e628
commit
b28314d33e
9 changed files with 67 additions and 38 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -3039,9 +3039,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipc-channel"
|
name = "ipc-channel"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ab3a34c91b7e84a72643bd75d1bac3afd241f78f9859fe0b5e5b2a6a75732c2"
|
checksum = "b8d038e61635aad6528b810a652e68efd09fc02551b6d108ae7c5c86285c6b40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
|
|
|
@ -274,10 +274,9 @@ impl RootCollection {
|
||||||
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
|
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
|
||||||
assert_in_script();
|
assert_in_script();
|
||||||
let roots = &mut *self.roots.get();
|
let roots = &mut *self.roots.get();
|
||||||
// FIXME: Use std::ptr::addr_eq after migrating to newer version of std.
|
|
||||||
match roots
|
match roots
|
||||||
.iter()
|
.iter()
|
||||||
.rposition(|r| std::ptr::eq(*r as *const (), object as *const ()))
|
.rposition(|r| std::ptr::addr_eq(*r as *const (), object as *const ()))
|
||||||
{
|
{
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
roots.remove(idx);
|
roots.remove(idx);
|
||||||
|
|
|
@ -10,7 +10,7 @@ with import (builtins.fetchTarball {
|
||||||
overlays = [
|
overlays = [
|
||||||
(import (builtins.fetchTarball {
|
(import (builtins.fetchTarball {
|
||||||
# Bumped the channel in rust-toolchain.toml? Bump this commit too!
|
# Bumped the channel in rust-toolchain.toml? Bump this commit too!
|
||||||
url = "https://github.com/oxalica/rust-overlay/archive/a0df72e106322b67e9c6e591fe870380bd0da0d5.tar.gz";
|
url = "https://github.com/oxalica/rust-overlay/archive/7f0e3ef7b7fbed78e12e5100851175d28af4b7c6.tar.gz";
|
||||||
}))
|
}))
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
# Be sure to update etc/shell.nix when bumping this!
|
# Be sure to update etc/shell.nix when bumping this!
|
||||||
channel = "1.74"
|
channel = "1.78.0"
|
||||||
|
|
||||||
components = [
|
components = [
|
||||||
# For support/crown
|
# For support/crown
|
||||||
|
|
|
@ -20,3 +20,7 @@ trace_in_no_trace_lint = []
|
||||||
[package.metadata.rust-analyzer]
|
[package.metadata.rust-analyzer]
|
||||||
# This crate uses #![feature(rustc_private)]
|
# This crate uses #![feature(rustc_private)]
|
||||||
rustc_private = true
|
rustc_private = true
|
||||||
|
|
||||||
|
# If you are working on crown, you might also need this in .vscode/settings.json.
|
||||||
|
# "rust-analyzer.check.command": "check",
|
||||||
|
# "rust-analyzer.rustc.source": "discover",
|
||||||
|
|
|
@ -9,10 +9,11 @@ use rustc_hir::{ImplItemRef, ItemKind, Node, OwnerId, PrimTy, TraitItemRef};
|
||||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
|
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||||
use rustc_middle::ty::{self, GenericArg, ParamEnv, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, GenericArg, ParamEnv, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_span::source_map::{ExpnKind, MacroKind, Span};
|
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||||
use rustc_span::symbol::{Ident, Symbol};
|
use rustc_span::symbol::{Ident, Symbol};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_trait_selection::infer::InferCtxtExt;
|
use rustc_trait_selection::infer::InferCtxtExt;
|
||||||
use rustc_type_ir::{FloatTy, IntTy, UintTy};
|
use rustc_type_ir::{FloatTy, IntTy, UintTy};
|
||||||
|
|
||||||
|
@ -69,8 +70,9 @@ macro_rules! symbols {
|
||||||
Stuff copied from clippy:
|
Stuff copied from clippy:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This is adapted from
|
||||||
|
// https://github.com/rust-lang/rust-clippy/blob/546408be416f0355a39601c1457b37727bc74395/clippy_utils/src/lib.rs#L517.
|
||||||
fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<Item = DefId> + 'tcx {
|
fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<Item = DefId> + 'tcx {
|
||||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
|
||||||
let ty = match name {
|
let ty = match name {
|
||||||
"bool" => SimplifiedType::Bool,
|
"bool" => SimplifiedType::Bool,
|
||||||
"char" => SimplifiedType::Char,
|
"char" => SimplifiedType::Char,
|
||||||
|
@ -96,10 +98,16 @@ fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<It
|
||||||
"u128" => SimplifiedType::Uint(UintTy::U128),
|
"u128" => SimplifiedType::Uint(UintTy::U128),
|
||||||
"f32" => SimplifiedType::Float(FloatTy::F32),
|
"f32" => SimplifiedType::Float(FloatTy::F32),
|
||||||
"f64" => SimplifiedType::Float(FloatTy::F64),
|
"f64" => SimplifiedType::Float(FloatTy::F64),
|
||||||
_ => return [].iter().copied(),
|
#[allow(trivial_casts)]
|
||||||
|
_ => {
|
||||||
|
return Result::<_, rustc_errors::ErrorGuaranteed>::Ok(&[] as &[_])
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.copied();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
tcx.incoherent_impls(ty).iter().copied()
|
tcx.incoherent_impls(ty).into_iter().flatten().copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Res> {
|
fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Res> {
|
||||||
|
@ -121,16 +129,18 @@ fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is adapted from clippy:
|
||||||
|
// https://github.com/rust-lang/rust-clippy/blob/546408be416f0355a39601c1457b37727bc74395/clippy_utils/src/lib.rs#L574.
|
||||||
fn local_item_children_by_name(tcx: TyCtxt<'_>, local_id: LocalDefId, name: Symbol) -> Vec<Res> {
|
fn local_item_children_by_name(tcx: TyCtxt<'_>, local_id: LocalDefId, name: Symbol) -> Vec<Res> {
|
||||||
let hir = tcx.hir();
|
let hir = tcx.hir();
|
||||||
|
|
||||||
let root_mod;
|
let root_mod;
|
||||||
let item_kind = match hir.find_by_def_id(local_id) {
|
let item_kind = match tcx.hir_node_by_def_id(local_id) {
|
||||||
Some(Node::Crate(r#mod)) => {
|
Node::Crate(r#mod) => {
|
||||||
root_mod = ItemKind::Mod(r#mod);
|
root_mod = ItemKind::Mod(r#mod);
|
||||||
&root_mod
|
&root_mod
|
||||||
},
|
},
|
||||||
Some(Node::Item(item)) => &item.kind,
|
Node::Item(item) => &item.kind,
|
||||||
_ => return Vec::new(),
|
_ => return Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,7 +235,8 @@ pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Vec<Res> {
|
||||||
// `impl S { ... }`
|
// `impl S { ... }`
|
||||||
let inherent_impl_children = tcx
|
let inherent_impl_children = tcx
|
||||||
.inherent_impls(def_id)
|
.inherent_impls(def_id)
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
||||||
|
|
||||||
let direct_children = item_children_by_name(tcx, def_id, segment);
|
let direct_children = item_children_by_name(tcx, def_id, segment);
|
||||||
|
@ -238,6 +249,16 @@ pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Vec<Res> {
|
||||||
resolutions
|
resolutions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option<DefId> {
|
||||||
|
def_path_res(cx, path)
|
||||||
|
.into_iter()
|
||||||
|
.find_map(|res| match res {
|
||||||
|
Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// These are special variants made from the above functions.
|
||||||
/// Resolves a def path like `std::vec::Vec`, but searches only local crate
|
/// Resolves a def path like `std::vec::Vec`, but searches only local crate
|
||||||
///
|
///
|
||||||
/// Also returns multiple results when there are multiple paths under the same name e.g. `std::vec`
|
/// Also returns multiple results when there are multiple paths under the same name e.g. `std::vec`
|
||||||
|
@ -259,7 +280,8 @@ pub fn def_local_res(cx: &LateContext<'_>, path: &str) -> Vec<Res> {
|
||||||
// `impl S { ... }`
|
// `impl S { ... }`
|
||||||
let inherent_impl_children = tcx
|
let inherent_impl_children = tcx
|
||||||
.inherent_impls(def_id)
|
.inherent_impls(def_id)
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
||||||
|
|
||||||
let direct_children = item_children_by_name(tcx, def_id, segment);
|
let direct_children = item_children_by_name(tcx, def_id, segment);
|
||||||
|
@ -271,15 +293,6 @@ pub fn def_local_res(cx: &LateContext<'_>, path: &str) -> Vec<Res> {
|
||||||
resolutions
|
resolutions
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option<DefId> {
|
|
||||||
def_path_res(cx, path)
|
|
||||||
.into_iter()
|
|
||||||
.find_map(|res| match res {
|
|
||||||
Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_local_trait_def_id(cx: &LateContext<'_>, path: &str) -> Option<DefId> {
|
pub fn get_local_trait_def_id(cx: &LateContext<'_>, path: &str) -> Option<DefId> {
|
||||||
def_local_res(cx, path)
|
def_local_res(cx, path)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
extern crate rustc_ast;
|
extern crate rustc_ast;
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
extern crate rustc_error_messages;
|
extern crate rustc_error_messages;
|
||||||
|
extern crate rustc_errors;
|
||||||
extern crate rustc_hir;
|
extern crate rustc_hir;
|
||||||
extern crate rustc_infer;
|
extern crate rustc_infer;
|
||||||
extern crate rustc_interface;
|
extern crate rustc_interface;
|
||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
|
extern crate rustc_log;
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
|
@ -60,8 +62,8 @@ impl Callbacks for MyCallbacks {
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let handler =
|
let handler =
|
||||||
rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
|
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
|
||||||
rustc_driver::init_env_logger(&handler, "CROWN_LOG");
|
rustc_driver::init_logger(&handler, rustc_log::LoggerConfig::from_env("CROWN_LOG"));
|
||||||
let args: Vec<_> = std::env::args().collect();
|
let args: Vec<_> = std::env::args().collect();
|
||||||
|
|
||||||
match rustc_driver::RunCompiler::new(&args, &mut MyCallbacks).run() {
|
match rustc_driver::RunCompiler::new(&args, &mut MyCallbacks).run() {
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn get_must_not_have_traceable(sym: &Symbols, attrs: &[Attribute]) -> Option<usi
|
||||||
TokenKind::Literal(lit) => lit.symbol.as_str().parse().unwrap(),
|
TokenKind::Literal(lit) => lit.symbol.as_str().parse().unwrap(),
|
||||||
_ => panic!("must_not_have_traceable expected integer literal here"),
|
_ => panic!("must_not_have_traceable expected integer literal here"),
|
||||||
},
|
},
|
||||||
TokenTree::Delimited(_, _, _) => {
|
TokenTree::Delimited(..) => {
|
||||||
todo!("must_not_have_traceable does not support multiple notraceable positions")
|
todo!("must_not_have_traceable does not support multiple notraceable positions")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -134,7 +134,9 @@ fn incorrect_no_trace<'tcx, I: Into<MultiSpan> + Copy>(
|
||||||
cx.lint(
|
cx.lint(
|
||||||
EMPTY_TRACE_IN_NO_TRACE,
|
EMPTY_TRACE_IN_NO_TRACE,
|
||||||
EMPTY_TRACE_IN_NO_TRACE_MSG,
|
EMPTY_TRACE_IN_NO_TRACE_MSG,
|
||||||
|lint| lint.set_span(span),
|
|lint| {
|
||||||
|
lint.span(span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
} else if is_jstraceable(cx, inner) {
|
} else if is_jstraceable(cx, inner) {
|
||||||
cx.lint(
|
cx.lint(
|
||||||
|
@ -143,7 +145,9 @@ fn incorrect_no_trace<'tcx, I: Into<MultiSpan> + Copy>(
|
||||||
"must_not_have_traceable marked wrapper must not have \
|
"must_not_have_traceable marked wrapper must not have \
|
||||||
jsmanaged inside on {pos}-th position. Consider removing the wrapper."
|
jsmanaged inside on {pos}-th position. Consider removing the wrapper."
|
||||||
),
|
),
|
||||||
|lint| lint.set_span(span),
|
|lint| {
|
||||||
|
lint.span(span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
|
|
@ -8,7 +8,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass, LintStore};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_session::declare_tool_lint;
|
use rustc_session::declare_tool_lint;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map;
|
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
|
|
||||||
use crate::common::{in_derive_expn, match_def_path};
|
use crate::common::{in_derive_expn, match_def_path};
|
||||||
|
@ -192,7 +191,9 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
UNROOTED_MUST_ROOT,
|
UNROOTED_MUST_ROOT,
|
||||||
"Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
|
"Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
|
||||||
on the struct definition to propagate",
|
on the struct definition to propagate",
|
||||||
|lint| lint.set_span(field.span),
|
|lint| {
|
||||||
|
lint.span(field.span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,9 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
"Type must be rooted, \
|
"Type must be rooted, \
|
||||||
use #[crown::unrooted_must_root_lint::must_root] \
|
use #[crown::unrooted_must_root_lint::must_root] \
|
||||||
on the enum definition to propagate",
|
on the enum definition to propagate",
|
||||||
|lint| lint.set_span(field.ty.span),
|
|lint| {
|
||||||
|
lint.span(field.ty.span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +235,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
kind: visit::FnKind<'tcx>,
|
kind: visit::FnKind<'tcx>,
|
||||||
decl: &'tcx hir::FnDecl,
|
decl: &'tcx hir::FnDecl,
|
||||||
body: &'tcx hir::Body,
|
body: &'tcx hir::Body,
|
||||||
span: source_map::Span,
|
span: rustc_span::Span,
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
let in_new_function = match kind {
|
let in_new_function = match kind {
|
||||||
|
@ -248,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
|
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
|
||||||
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
|
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
|
||||||
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
||||||
lint.set_span(arg.span)
|
lint.span(arg.span);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +260,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
|
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
|
||||||
{
|
{
|
||||||
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
cx.lint(UNROOTED_MUST_ROOT, "Type must be rooted", |lint| {
|
||||||
lint.set_span(decl.output.span())
|
lint.span(decl.output.span());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +292,9 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
|
||||||
cx.lint(
|
cx.lint(
|
||||||
UNROOTED_MUST_ROOT,
|
UNROOTED_MUST_ROOT,
|
||||||
format!("Expression of type {:?} must be rooted", ty),
|
format!("Expression of type {:?} must be rooted", ty),
|
||||||
|lint| lint.set_span(subexpr.span),
|
|lint| {
|
||||||
|
lint.span(subexpr.span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -331,7 +336,9 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
|
||||||
cx.lint(
|
cx.lint(
|
||||||
UNROOTED_MUST_ROOT,
|
UNROOTED_MUST_ROOT,
|
||||||
format!("Expression of type {:?} must be rooted", ty),
|
format!("Expression of type {:?} must be rooted", ty),
|
||||||
|lint| lint.set_span(pat.span),
|
|lint| {
|
||||||
|
lint.span(pat.span);
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue